

## FIGURE 6

# load, combine data
library(rio)
library(tidyverse)

# deal with dates
library(zoo)

# make better axis labels
library(scales)



# LOAD DATA
approval <- import("EAD+2.0+quarter+101019.csv") %>%
  filter(Country=="Mexico") %>%
  select(Country,year,quarter,Approval_Smoothed,NET_Smoothed) %>%
  rename(country = Country, approval = Approval_Smoothed, net_approval = NET_Smoothed) %>%
  unite(time,year,quarter,sep = "Q") %>%
  mutate(time = as.yearqtr(time, format = "%YQ%q"))

# get election quarters
dpi <- import("DPI2020.dta") %>%
  select(countryname,year,exelec,dateexec) %>%
  filter(countryname=="Mexico") %>%  
  mutate_all(~na_if(., '-999')) %>%
  filter(exelec==1) %>%
  select(c(-countryname,exelec)) 

ggplot(approval, aes(x=time, y=approval)) + geom_line() + theme_minimal() + 
  scale_x_yearqtr(limits = c(min(approval$time), max(approval$time)), format = "%Y") +
  xlab("Year") + ylab("Executive Approval") +
  geom_point(x=1994.5, y=54.67744, size=2) + 
  geom_point(x=1997, y=46.56342, size=2) + 
  geom_point(x=2000.5, y=58.02409, size=2) +
  geom_point(x=2006.5, y=55.68087, size=2) +
  geom_point(x=2012.5, y=52.31712, size=2) +
  geom_point(x=2018.5, y=29.11577, size=2) +
  geom_vline(xintercept = 2000.75, color="#21908CFF") +
  geom_vline(xintercept = 2001, color="#21908CFF") +
  geom_vline(xintercept = 2006, color="#21908CFF") +
  geom_vline(xintercept = 2007.25, color="#21908CFF") +
  geom_vline(xintercept = 2013.75, color="#21908CFF") +
  geom_vline(xintercept = 2014.5, color="#21908CFF") +
  scale_y_continuous(labels = label_percent(scale = 1))

# ggsave("figure6.pdf", height = 5, width = 7.5)
